﻿using System;
using System.Web;
using Framework;

namespace Enterprise.Admin.Handle.Project
{
    public partial class Add : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var filedata = new HttpPostedFileWrapper(Request.Files["Filedata"]);
                var name = Fq("CoName").SafeToString();
                var nameEn = Fq("CoNameEn").SafeToString();
                var content = Fq("CoContent").SafeToString();
                var contentEn = Fq("CoContentEn").SafeToString();
                var keyword = Fq("CoKeyword").SafeToString();
                var keywordEn = Fq("CoKeywordEn").SafeToString();
                var description = Fq("CoDescription").SafeToString();
                var descriptionEn = Fq("CoDescriptionEn").SafeToString();
                var sorts = Fq("CoSort").SafeToInt();
                var projectService = new ProjectService();
                projectService.Add(name, nameEn, content, contentEn, keyword, keywordEn, description, descriptionEn, DateTime.Now, sorts, false, filedata);
                result = new { state = true, message = "添加成功！" };
            }
            catch (Exception ex)
            {
                result = new { state = false, message = ex.Message };
            }
            Response.Write(result.Serialization());
            Response.End();
        }
    }
}